package com.reason.user.controller;

import com.reason.common.pojo.Result;
import com.reason.common.pojo.StatusCode;
import com.reason.user.pojo.Customer;
import com.reason.user.pojo.Economics;
import com.reason.user.service.EconomicsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author  yulongjun
 * @date 2020/6/29 10:42 下午
 */
@RestController
@RequestMapping("/economics")
@CrossOrigin
public class EconomicsController {
    @Autowired
    private EconomicsService economicsService;

    /**
     * 查询所有
     * @return
     */
    @RequestMapping("/findAll")
    public Result<List<Economics>> findAll() {

        List <Economics> brandList = economicsService.findBrandList();
        System.out.println(brandList);
        return new Result (true, StatusCode.OK, "查询成功", brandList);
    }
    /**
     * 根据ID查询Economics
     * @param Id
     * @return
     */
    @GetMapping("/findById/{Id}")
    public Economics findById(@PathVariable("Id") Long Id){
        Economics economics=economicsService.findByID(Id);
        System.out.println(economics);
        if(economics==null){
            return null;
        }
    return economics;
    }
}
